<template>
  <div>
    <CERadioGroup :options="options" v-model="selectValue" />
    <CESelect :options="options" v-model="selectValue" />
  </div>
</template>

<script setup lang="ts">
import { CESelect } from '@/components'
import { onMounted, ref } from 'vue'
const options = [
  { value: 1, label: '数据1' },
  { value: 2, label: '数据2' },
  { value: 3, label: '数据3' }
]
const selectValue = ref('')

const mockGetData = (): Promise<{ id: number }> => {
  return new Promise((resolve) => {
    resolve({ id: 2 })
  })
}

const mockData2 = (options: {
  id: number
}): Promise<{ id: number; name: string; age: number }> => {
  return new Promise((resolve) => {
    resolve({ id: 2, name: '张三', age: 18 })
  })
}

const init = async () => {
  const res = await mockGetData()
  if (res.id) {
    const res2 = await mockData2({ id: res.id })
    console.log(res2, 'res2')
  }
}

onMounted(() => {
  init()
})

const url = new URL('@/assets/json/anhui.json', import.meta.url).href
console.log(url, 'import.meta.url')
</script>

<style scoped></style>
